package edu.mobbuzz.daf.facade;

import edu.mobbuzz.daf.bean.User;
import edu.mobbuzz.daf.dao.IUserDao;

public class UserFacade extends BaseFacade{
	private IUserDao userDao;
	
	public IUserDao getUserDao() {
		if(userDao==null)
			userDao = (IUserDao)getFactory().getBean("userDao");
		return userDao;
	}
	
	public boolean checkUserExist(String username){
		User _user = (User)getUserDao().findByPrimaryKey(username);
		if(_user!=null){
			return true;
		}else{
			return false;
		}
		
	}
	
	public boolean addUser(String username){
		User _user = new User();
		_user.setUsername(username);
		
		try{
			getUserDao().insert(_user);
			return true;
		}catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		
		
		
	}
}
